//
//  HMAddCaseController.m
//  仿真开发
//
//  Created by B.HOPE on 2017/3/25.
//  Copyright © 2017年 B.HOPE. All rights reserved.
//

#import "HMAddCaseController.h"
#import "HMAddCaseThreeCell.h"

@interface HMAddCaseController ()

//@property (nonatomic, strong) HMAddCaseThreeCell *cell;

//@property (nonatomic, assign) NSInteger num;

@property (nonatomic, strong) NSMutableArray *arrayModel;

@end

@implementation HMAddCaseController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    _num = -1;
    _arrayModel = [[NSMutableArray alloc] init];
    
    [self setupUI];
}

- (void) setupUI
{
    UIBarButtonItem *yesBtn = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(clickBtn:)];
    
    self.navigationItem.rightBarButtonItem = yesBtn;
    
    [self.tableView registerClass:[HMAddCaseThreeCell class] forCellReuseIdentifier:@"cell"];
}

- (void)clickBtn:(UIBarButtonItem *)sender
{
    [self.delegate addCase:self Array:_arrayModel.copy];
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HMAddCaseThreeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.str = _array[indexPath.row];
    
//    if (_num == indexPath.row)
//    {
//        _cell.type = indexPath.row;
//    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *str = _array[indexPath.row];
    
    [_arrayModel addObject:str];
    
//    _num = indexPath.row;
    
    [self.tableView reloadData];
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    HMAddCaseThreeCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.yesImg.hidden = NO;
}

@end
